/* eslint-disable react-hooks/exhaustive-deps */
import React,{ Fragment,useState ,useEffect,useRef} from "react";
import { useNavigate, useLocation, useParams } from 'react-router-dom';
import './index.less'


import { Button, Upload } from 'antd';

function MyUpload(props) {
  const uploadProps = {
    name: 'file',
    action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
    maxCount:1,
    listType:props.type ==='video' ? 'text' : "picture-card",
    onChange(info) {
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (info.file.status === 'done') {
      } else if (info.file.status === 'error') {
      }
    },
  };
  return (
    <Fragment >
       <Upload {...uploadProps}>
          
          {
            props.type !== 'video' ? 
            (
              '上传文件'
            ) : 
            (
              <Button>
                上传文件
              </Button>
            )
          }
        </Upload>
    </Fragment>

  )
}

export default MyUpload;